package com.yix.admin.modules.system.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.yix.common.base.BaseDTO;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author wdx
 * @version 1.0
 * @Description TODO
 * @date 2021/1/28 8:59
 */
@Getter
@Setter
public class SysDeptDto  extends BaseDTO implements Serializable {

    private String id;

    private String name;

    private Boolean enabled;

    private Integer sort;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<SysDeptDto> children;

    private String pid;

    private Integer subCount;

    public Boolean getHasChildren() {
        return subCount > 0;
    }

    public Boolean getLeaf() {
        return subCount <= 0;
    }

    public String getLabel() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SysDeptDto deptDto = (SysDeptDto) o;
        return Objects.equals(id, deptDto.id) &&
                Objects.equals(name, deptDto.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }
}
